package cn.edu.sjtu.permission;

import java.util.HashMap;
import java.util.HashSet;

import cn.edu.sjtu.DedexerPlus;

public abstract class PermissionChecker {
	protected String pfPath;
	protected HashMap<String, String> pMap;
	protected HashSet<String> cSet;
 	
	public PermissionChecker(String path) {
		pfPath = path;
		pMap = new HashMap<String, String>();
		cSet = new HashSet<String>();
		
		if (pfPath != null) {
			setPermissionMap(pfPath, pMap);
		}
	}
	
	public void setAppPermission(String s) {
		cSet.add(s);
	}
	
	public static void setPermissionSet(HashSet<String> hs, String s) {
		if (s != null) {
			String[] ps = s.split("&");
			if (ps != null) {
				for (String p: ps) {
					hs.add(p);
				}
			}
		}
	}
	
	abstract public void checkPermission(DedexerPlus ddxp);
	
	abstract protected void setPermissionMap(String path, HashMap<String, String> map);
	
	abstract public void analyse(HashSet<String> pset, String func, String[] regValue);
}
